package lu.med.praxiswahl.wahlumed.client.arztdatabase;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.Toolkit;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

import lu.med.praxiswahl.wahlumed.client.utilities.UniCode;
import lu.med.praxiswahl.wahlumed.client.wclient.Main;


/**
 * 
 * @author Lars Holger Roth
 */
@SuppressWarnings("serial")
public class ArztOptionsDialog extends JFrame
{
    private ArztTableModel model;
    private ArztTable table;

    public ArztOptionsDialog(Main dataManager)
    {
	super(UniCode.getAE() + "rzte Datenbank");
	this.setAlwaysOnTop(true);
	this.setLayout(new BorderLayout());

	// Erstellt das Datenmodel
	model = new ArztTableModel(dataManager);
	table = new ArztTable(model);
	JScrollPane scrollPane = new JScrollPane(table);
	this.add(scrollPane, BorderLayout.CENTER);
	JPanel buttonPanel = new JPanel(new GridLayout(1, 0));
	JButton newDatasetButton = new JButton("Neuer Eintrag");
	newDatasetButton.addActionListener(new ArztNewDatasetActionListener(
		this, model));
	JButton dropButton = new JButton("L" + UniCode.getoe() + "schen");
	dropButton.addActionListener(new ArztDeleteActionListener(model));
	JButton curButton = new JButton("Aktualisieren");
	curButton.addActionListener(new ArztRefreshActionListener(model));
	buttonPanel.add(newDatasetButton);
	buttonPanel.add(dropButton);
	buttonPanel.add(curButton);
	this.add(buttonPanel, BorderLayout.NORTH);

	// this.setSize(800,600);
	Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
	this.setSize((int) dim.getWidth(), (int) dim.getHeight());
	this.setLocation(0, 0);
	this.setVisible(true);
    }

    @Override
    public void setVisible(boolean in)
    {
	super.setVisible(in);
	this.setExtendedState(Frame.MAXIMIZED_BOTH);
    }

}
